]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspace: Make room for a second geometry to keep track of
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 25 Feb 2013 23:25:27 +0000 (18:25 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 22 Apr 2013 18:01:00 +0000 (14:01 -0400)
As we want to eventually track two geometries, we need to rename
our very plain "_x, _y, _width, _height". While we could just prefix
them, I think that stuffing them in an object makes more sense.

At the same time, make the variable and method name more descriptive
by adding such a prefix, as well as a bit of documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=694469

js/ui/overviewControls.js
js/ui/viewSelector.js
js/ui/workspace.js
js/ui/workspacesView.js

index 7563975df9f553253bb3b4b7404030cff27aba63..313c4501dd39feb89ef4d3b75f079ecbd9ef16e8 100644 (file)
@@ -556,7 +556,7 @@ const ControlsManager = new Lang.Class({
         else
             geometry.x += thumbnailsWidth;
 
-        this.viewSelector.setWorkspacesGeometry(geometry);
+        this.viewSelector.setWorkspacesFullGeometry(geometry);
     },
 
     _setVisibility: function() {
index a7ad1b53b58dfdb94dd5817189487fcb312deb93..ade52d0a8b7d918cb008d6a7514006437bda0e19 100644 (file)
@@ -186,8 +186,8 @@ const ViewSelector = new Lang.Class({
             Main.overview.fadeInDesktop();
     },
 
-    setWorkspacesGeometry: function(geom) {
-        this._workspacesDisplay.setWorkspacesGeometry(geom);
+    setWorkspacesFullGeometry: function(geom) {
+        this._workspacesDisplay.setWorkspacesFullGeometry(geom);
     },
 
     hide: function() {
index d3c380e7eaf496769ebc8183f69a6f18baa9861c..30c09fac509cf58f242d975a3b184714f5a92502 100644 (file)
@@ -901,10 +901,11 @@ const Workspace = new Lang.Class({
         // When dragging a window, we use this slot for reserve space.
         this._reservedSlot = null;
         this.metaWorkspace = metaWorkspace;
-        this._x = 0;
-        this._y = 0;
-        this._width = 0;
-        this._height = 0;
+
+        // The full geometry is the geometry we should try and position
+        // windows for. The actual geometry we allocate may be less than
+        // this, like if the workspace switcher is slid out.
+        this._fullGeometry = null;
 
         this.monitorIndex = monitorIndex;
         this._monitor = Main.layoutManager.monitors[this.monitorIndex];
@@ -956,11 +957,8 @@ const Workspace = new Lang.Class({
         this._positionWindowsId = 0;
     },
 
-    setGeometry: function(geom) {
-        this._x = geom.x;
-        this._y = geom.y;
-        this._width = geom.width;
-        this._height = geom.height;
+    setFullGeometry: function(geom) {
+        this._fullGeometry = geom;
 
         Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
             this._dropRect.set_position(geom.x, geom.y);
@@ -1148,8 +1146,8 @@ const Workspace = new Lang.Class({
         let [x, y, mask] = global.get_pointer();
 
         let pointerHasMoved = (this._cursorX != x && this._cursorY != y);
-        let inWorkspace = (this._x < x && x < this._x + this._width &&
-                           this._y < y && y < this._y + this._height);
+        let inWorkspace = (this._fullGeometry.x < x && x < this._fullGeometry.x + this._fullGeometry.width &&
+                           this._fullGeometry.y < y && y < this._fullGeometry.y + this._fullGeometry.height);
 
         if (pointerHasMoved && inWorkspace) {
             // store current cursor position
@@ -1538,10 +1536,10 @@ const Workspace = new Lang.Class({
         padding.right += rightBorder;
 
         let area = {
-            x: this._x + padding.left,
-            y: this._y + padding.top,
-            width: this._width - padding.left - padding.right,
-            height: this._height - padding.top - padding.bottom,
+            x: this._fullGeometry.x + padding.left,
+            y: this._fullGeometry.y + padding.top,
+            width: this._fullGeometry.width - padding.left - padding.right,
+            height: this._fullGeometry.height - padding.top - padding.bottom,
         };
 
         let layout = this._computeLayout(windows, area, rowSpacing, columnSpacing);
index 7cb3b7e58af7d454633ec7a7682676392a092f67..c6a998c538ed9e55dbe32dc98f2d9bff48403766 100644 (file)
@@ -23,6 +23,18 @@ const MAX_WORKSPACES = 16;
 
 const OVERRIDE_SCHEMA = 'org.gnome.shell.overrides';
 
+function rectEqual(one, two) {
+    if (one == two)
+        return true;
+
+    if (!one || !two)
+        return false;
+
+    return (one.x == two.x &&
+            one.y == two.y &&
+            one.width == two.width &&
+            one.height == two.height);
+}
 
 const WorkspacesView = new Lang.Class({
     Name: 'WorkspacesView',
@@ -43,10 +55,8 @@ const WorkspacesView = new Lang.Class({
                 this._updateWorkspaceActors(false);
             }));
 
-        this._width = 0;
-        this._height = 0;
-        this._x = 0;
-        this._y = 0;
+        this._fullGeometry = null;
+
         this._spacing = 0;
         this._animating = false; // tweening
         this._scrolling = false; // swipe-scrolling
@@ -85,8 +95,8 @@ const WorkspacesView = new Lang.Class({
         this._overviewShownId =
             Main.overview.connect('shown',
                                  Lang.bind(this, function() {
-                this.actor.set_clip(this._x, this._y,
-                                    this._width, this._height);
+                this.actor.set_clip(this._fullGeometry.x, this._fullGeometry.y,
+                                    this._fullGeometry.width, this._fullGeometry.height);
         }));
 
         this.scrollAdjustment = new St.Adjustment({ value: activeWorkspaceIndex,
@@ -124,7 +134,7 @@ const WorkspacesView = new Lang.Class({
                 continue;
 
             let ws = new Workspace.Workspace(null, i);
-            ws.setGeometry(monitors[i]);
+            ws.setFullGeometry(monitors[i]);
             global.overlay_group.add_actor(ws.actor);
             this._extraWorkspaces.push(ws);
         }
@@ -136,18 +146,14 @@ const WorkspacesView = new Lang.Class({
         this._extraWorkspaces = [];
     },
 
-    setGeometry: function(geom) {
-        if (this._x == geom.x && this._y == geom.y &&
-            this._width == geom.width && this._height == geom.height)
+    setFullGeometry: function(geom) {
+        if (rectEqual(this._fullGeometry, geom))
             return;
 
-        this._width = geom.width;
-        this._height = geom.height;
-        this._x = geom.x;
-        this._y = geom.y;
+        this._fullGeometry = geom;
 
         for (let i = 0; i < this._workspaces.length; i++)
-            this._workspaces[i].setGeometry(geom);
+            this._workspaces[i].setFullGeometry(geom);
     },
 
     _lookupWorkspaceForMetaWindow: function (metaWindow) {
@@ -207,7 +213,7 @@ const WorkspacesView = new Lang.Class({
 
             Tweener.removeTweens(workspace.actor);
 
-            let y = (w - active) * (this._height + this._spacing);
+            let y = (w - active) * (this._fullGeometry.height + this._spacing);
 
             if (showAnimation) {
                 let params = { y: y,
@@ -278,10 +284,7 @@ const WorkspacesView = new Lang.Class({
 
         if (newNumWorkspaces > oldNumWorkspaces) {
             for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
-                this._workspaces[w].setGeometry({ x: this._x,
-                                                  y: this._y,
-                                                  width: this._width,
-                                                  height: this._height });
+                this._workspaces[w].setFullGeometry(this._fullGeometry);
                 this.actor.add_actor(this._workspaces[w].actor);
             }
 
@@ -482,6 +485,8 @@ const WorkspacesDisplay = new Lang.Class({
 
         this._notifyOpacityId = 0;
         this._scrollEventId = 0;
+
+        this._fullGeometry = null;
     },
 
     _onPan: function(action) {
@@ -570,7 +575,7 @@ const WorkspacesDisplay = new Lang.Class({
             this._workspacesViews.push(view);
         }
 
-        this._updateWorkspacesGeometry();
+        this._updateWorkspacesFullGeometry();
 
         for (let i = 0; i < this._workspacesViews.length; i++)
             global.overlay_group.add_actor(this._workspacesViews[i].actor);
@@ -633,12 +638,12 @@ const WorkspacesDisplay = new Lang.Class({
     // This geometry should always be the fullest geometry
     // the workspaces switcher can ever be allocated, as if
     // the sliding controls were never slid in at all.
-    setWorkspacesGeometry: function(geom) {
-        this._geometry = geom;
-        this._updateWorkspacesGeometry();
+    setWorkspacesFullGeometry: function(geom) {
+        this._fullGeometry = geom;
+        this._updateWorkspacesFullGeometry();
     },
 
-    _updateWorkspacesGeometry: function() {
+    _updateWorkspacesFullGeometry: function() {
         if (!this._workspacesViews.length)
             return;
 
@@ -646,10 +651,10 @@ const WorkspacesDisplay = new Lang.Class({
         let m = 0;
         for (let i = 0; i < monitors.length; i++) {
             if (i == this._primaryIndex) {
-                this._workspacesViews[m].setGeometry(this._geometry);
+                this._workspacesViews[m].setFullGeometry(this._fullGeometry);
                 m++;
             } else if (!this._workspacesOnlyOnPrimary) {
-                this._workspacesViews[m].setGeometry(monitors[i]);
+                this._workspacesViews[m].setFullGeometry(monitors[i]);
                 m++;
             }
         }